﻿using System.Collections.Generic;
using System.Linq;
using ManagerClient.Manage.Logic;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Unity;

namespace ManagerClient
{
    public class MainViewModel
    {
        private readonly List<TabPageViewModelBase> listOfViewModels;


        public MainViewModel(IUnityContainer container)
        {
            ShowMailCommand = new DelegateCommand(ShowMail);
            var mailControlViewModel = container.Resolve<MailControlViewModel>();
            var manageMenuViewModel = container.Resolve<ManageMenuViewModel>();
            var manageDepositsViewModel = container.Resolve<ManageDepositsViewModel>();

            listOfViewModels = new List<TabPageViewModelBase>
                {
                    mailControlViewModel,
                    manageMenuViewModel,
                    manageDepositsViewModel
                };
            SelectedItem = ListOfViewModels.FirstOrDefault();
        }


        public List<TabPageViewModelBase> ListOfViewModels
        {
            get
            {
                return
                    listOfViewModels;
            }
        }

        public TabPageViewModelBase SelectedItem { get; set; }
        public DelegateCommand ShowMailCommand { get; set; }


        public bool IsUserAManager
        {
            get { return true; }
        }


        private void ShowMail()
        {
            SelectedItem = ListOfViewModels.FirstOrDefault(x => x is MailControlViewModel);
        }
    }
}